package com.degon.hsyl.choosefile;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.permissionx.guolindev.PermissionX;
import com.permissionx.guolindev.callback.RequestCallback;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    private Button openFileChoosePage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initViews();

        openFileChoosePage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                PermissionX.init(MainActivity.this)
                        .permissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                        .request(new RequestCallback() {
                            @Override
                            public void onResult(boolean allGranted, @NonNull List<String> grantedList, @NonNull List<String> deniedList) {
                                Intent intent = new Intent(MainActivity.this, ChooseFileActivity.class);
                                startActivity(intent);
                            }
                        });
            }
        });
    }

    private void initViews() {
        openFileChoosePage = findViewById(R.id.open_file_choose_page);
    }

}
